﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Common;
using System.Collections;

namespace Library.Entity
{
    public class BookTransaction : IdCodeName
    {
        public int BookStockId = 0;
        public int BookId = 0;
        public DateTime TransactionDate = DateTime.Today;// StaticValue.NullDate;
        public TransactionType TransactionType = TransactionType.Borrow;
        public DateTime BorrowDate = DateTime.Today;// StaticValue.NullDate;
        public DateTime ReturnDate = DateTime.Today;// StaticValue.NullDate;
        public int BorrowId = 0;
        public decimal Quantity = 0;
        public int MemberId = 0;

        public Member Member = null;
        public Book Book = null;
        public IList BorrowList = new ArrayList();
        public BookTransaction()
        {
        }
        public BookTransaction(DbDataReader dr)
        {
            Id = DataConversion.ConvertToInt32(dr, "Id");
            Code = DataConversion.ConvertToString(dr, "Code");
            Name = DataConversion.ConvertToString(dr, "Name");
            Remark = DataConversion.ConvertToString(dr, "Remark");
            CreatedDate = DataConversion.ConvertToDateTime(dr, "CreatedDate");
            ModifiedDate = DataConversion.ConvertToDateTime(dr, "ModifiedDate");
            CreatedUserId = DataConversion.ConvertToInt32(dr, "CreatedUserId");
            ModifiedUserId = DataConversion.ConvertToInt32(dr, "ModifiedUserId");

            BookId = DataConversion.ConvertToInt32(dr, "BookId");
            BookStockId = DataConversion.ConvertToInt32(dr, "BookStockId");
            TransactionDate = DataConversion.ConvertToDateTime(dr, "TransactionDate");
            TransactionType = (TransactionType)DataConversion.ConvertToEnum(dr, "TransactionType", typeof(TransactionType));
            BorrowDate = DataConversion.ConvertToDateTime(dr, "BorrowDate");
            ReturnDate = DataConversion.ConvertToDateTime(dr, "ReturnDate");
            BorrowId = DataConversion.ConvertToInt32(dr, "BorrowId");
            Quantity = DataConversion.ConvertToDecimal(dr, "Quantity");
            MemberId = DataConversion.ConvertToInt32(dr, "MemberId");
        }
    }
}